import apiService from './plugins/apiService'
import apiConstants from './plugins/apiConstants'
import filterUtil from './plugins/filterUtil'
import dictUtil from './plugins/dictUtil'
import nfsUtil from './plugins/nfsUtil'

var as = apiService(Vue);
var ezjsUtil = {
  constants: {
    api: apiConstants
  },
  request: as.request,
  buildUrl: as.buildFullUrl,

  filterUtil: filterUtil,
  dictUtil: dictUtil,
  nfsUtil: nfsUtil,
  eventHub: new Vue()

}

function plugin(Vue) {

  if (plugin.installed) {
    return;
  }
  Vue.apiService = apiService(Vue);
  Vue.ezjsUtil = ezjsUtil;


}

if (typeof window !== 'undefined' && window.Vue) {
  window.Vue.use(plugin);
}
if (typeof window !== 'undefined') {
  window.ezjsUtil = ezjsUtil
}

export default plugin;
